home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / fax / src / faxd / Class2.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  6KB  |  141 lines

  1. /*    $Header: /usr/people/sam/fax/faxd/RCS/Class2.h,v 1.56 1994/04/08 19:43:29 sam Rel $ */
  2. /*
  3.  * Copyright (c) 1990, 1991, 1992, 1993, 1994 Sam Leffler
  4.  * Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc.
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and 
  7.  * its documentation for any purpose is hereby granted without fee, provided
  8.  * that (i) the above copyright notices and this permission notice appear in
  9.  * all copies of the software and related documentation, and (ii) the names of
  10.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  11.  * publicity relating to the software without the specific, prior written
  12.  * permission of Sam Leffler and Silicon Graphics.
  13.  * 
  14.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  15.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  16.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  17.  * 
  18.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  19.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  20.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  22.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  23.  * OF THIS SOFTWARE.
  24.  */
  25. #ifndef _CLASS2_
  26. #define    _CLASS2_
  27. /*
  28.  * Base class for a Class 2 and Class 2.0 Modem Drivers.
  29.  */
  30. #include "FaxModem.h"
  31. #include <stdarg.h>
  32.  
  33. class Class2Modem : public FaxModem {
  34. protected:
  35.     fxStr    classCmd;        // set class command
  36.     fxStr    cqCmds;            // copy quality setup commands
  37.     fxStr    tbcCmd;            // modem-host communication mode command
  38.     fxStr    crCmd;            // enable receiving command
  39.     fxStr    phctoCmd;        // set Phase C timeout command
  40.     fxStr    bugCmd;            // enable HDLC tracing command
  41.     fxStr    lidCmd;            // set local ID command
  42.     fxStr    dccCmd;            // set configuration parameters command
  43.     fxStr    dccQueryCmd;        // modem capabilities query command
  44.     fxStr    disCmd;            // set session parameters command
  45.     fxStr    cigCmd;            // set polling ID string command
  46.     fxStr    splCmd;            // set polling request command
  47.     fxStr    nrCmd;            // negotiation message reporting control
  48.     fxStr    pieCmd;            // procedure interrupt enable control
  49.     fxStr    borCmd;            // set bit order command
  50.     fxStr    abortCmd;        // abort session command
  51.     u_int    serviceType;        // modem service required
  52.  
  53.     Class2Params params;        // current params during send
  54.     char    recvDataTrigger;    // char to send to start recv'ing data
  55.     char    hangupCode[4];        // hangup reason (from modem)
  56.     long    group3opts;        // for writing received TIFF
  57.  
  58. // modem setup stuff
  59.     void setupDefault(fxStr&, const fxStr&, const char*);
  60.     virtual fxBool setupModem();
  61.     virtual fxBool setupModel(fxStr& model);
  62.     virtual fxBool setupRevision(fxStr& rev);
  63.     virtual fxBool setupDCC();
  64.     virtual fxBool setupClass2Parameters();
  65. // transmission support
  66.     fxBool    dataTransfer();
  67.  
  68.     virtual fxBool sendPage(TIFF* tif) = 0;
  69.     virtual fxBool pageDone(u_int ppm, u_int& ppr) = 0;
  70. // reception support
  71.     const AnswerMsg* findAnswer(const char*);
  72.     fxBool    recvDCS(const char*);
  73.     fxBool    recvPageData(TIFF*);
  74.     fxBool    recvPPM(TIFF*, int& ppr);
  75.     void    recvData(TIFF*, u_char* buf, int n);
  76.     fxBool    parseFPTS(TIFF*, const char* cp, int& ppr);
  77.  
  78.     virtual fxBool recvPageDLEData(TIFF*) = 0;
  79. // miscellaneous
  80.     enum {            // Class 2-specific AT responses
  81.     AT_FHNG        = 100,    // remote hangup
  82.     AT_FCON        = 101,    // fax connection status
  83.     AT_FPOLL    = 102,    // document available for polling status
  84.     AT_FDIS        = 103,    // DIS received status
  85.     AT_FNSF        = 104,    // NSF received status
  86.     AT_FCSI        = 105,    // CSI received status
  87.     AT_FPTS        = 106,    // post-page status
  88.     AT_FDCS        = 107,    // DCS received status
  89.     AT_FNSS        = 108,    // NSS received status
  90.     AT_FTSI        = 109,    // TSI received status
  91.     AT_FET        = 110,    // post-page-response status
  92.     AT_FVO        = 111,    // voice transition status
  93.     };
  94.     virtual ATResponse atResponse(char* buf, long ms = 30*1000) = 0;
  95.     fxBool    waitFor(ATResponse wanted, long ms = 30*1000);
  96.     fxStr    stripQuotes(const char*);
  97. // hangup processing
  98.     void    processHangup(const char*);
  99.     fxBool    isNormalHangup();
  100.     const char*    hangupCause(const char* code);
  101.     void    tracePPR(const char* dir, u_int ppr);
  102.     void    tracePPM(const char* dir, u_int ppm);
  103. // class 2 command support routines
  104.     fxBool    class2Cmd(const char* cmd, const Class2Params& p);
  105.     fxBool    class2Cmd(const char* cmd);
  106.     fxBool    class2Cmd(const char* cmd, int a0);
  107.     fxBool    class2Cmd(const char* cmd, const char* s);
  108. // parsing routines for capability¶meter strings
  109.     fxBool    parseClass2Capabilities(const char* cap, Class2Params&);
  110.     fxBool    parseRange(const char*, Class2Params&);
  111.     const char* skipStatus(const char*);
  112.  
  113.     Class2Modem(FaxServer&, const ModemConfig&);
  114. public:
  115.     virtual ~Class2Modem();
  116.  
  117. // send support
  118.     CallStatus    dialResponse();
  119.     fxBool    getPrologue(Class2Params&, u_int& nsf, fxStr&, fxBool& hasDoc);
  120.     void    sendBegin();
  121.     fxBool    sendPhaseB(TIFF* tif, Class2Params&, FaxMachineInfo&,
  122.             fxStr& pph, fxStr& emsg);
  123.  
  124. // receive support
  125.     fxBool    recvBegin(fxStr& emsg);
  126.     fxBool    recvPage(TIFF*, int& ppm, fxStr& emsg);
  127.     fxBool    recvEnd(fxStr& emsg);
  128.  
  129. // polling support
  130.     fxBool    requestToPoll();
  131.     fxBool    pollBegin(const fxStr& pollID, fxStr& emsg);
  132.  
  133. // miscellaneous
  134.     fxBool    dataService();            // establish data service
  135.     fxBool    voiceService();            // establish voice service
  136.     fxBool    reset(long ms = 5*1000);    // reset modem
  137.     fxBool    abort(long ms = 5*1000);    // abort session
  138.     void    setLID(const fxStr& number);    // set local id string
  139. };
  140. #endif /* _CLASS2_ */
  141.